function [tst] = kneu_test_logreg(R,TEST)

% Generates predictions using a trained logistic regression model
%
% [ACTS SCRATCHPAD] = TEST_RIDGE(TESTPATS,TESTTARGS,SCRATCHPAD)
%
% License:
%=====================================================================
%
% This is part of the Princeton MVPA toolbox, released under
% the GPL. See http://www.csbmb.princeton.edu/mvpa for more
% information.
% 
% The Princeton MVPA toolbox is available free and
% unsupported to those who might find it useful. We do not
% take any responsibility whatsoever for any problems that
% you have related to the use of the MVPA toolbox.
%
% ======================================================================


if R.constant
  TEST = [ones(size(TEST,1),1), TEST];
end

acts = exp(R.logreg.betas'*TEST')./(1+exp(R.logreg.betas'*TEST'));
tst.likelihoods = acts';
[maxProp, maxIdx]=max(tst.likelihoods,[],2);
tst.prediction=R.classes(maxIdx);
